package com.android.meige.fragment.member;


import android.content.Intent;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.SeekBar;
import android.widget.TextView;

import com.android.meige.R;
import com.android.meige.activity.BaseObject;
import com.android.meige.activity.MainTab;
import com.android.meige.activity.PayActivity;
import com.android.meige.activity.mine.LoginActivity;
import com.android.meige.activity.mine.TransparentActivity;
import com.android.meige.adapt.GridDetaillikeAdapt;
import com.android.meige.fragment.BaseLazyFragment;
import com.android.meige.model.detail.Banner;
import com.android.meige.model.detail.BannerCallback;
import com.android.meige.model.detail.MainDetail;
import com.android.meige.model.detail.ShareDetail;
import com.android.meige.model.detail.ShareDteailCallback;
import com.android.meige.model.group.MainList;
import com.android.meige.model.group.MainListCallback;
import com.android.meige.utils.ConstantsUrl;
import com.android.meige.utils.HttpUtils;
import com.android.meige.utils.LoginState;
import com.android.meige.utils.MyLog;
import com.android.meige.utils.ObjectUtils;
import com.android.meige.view.CheckInchPopWindow1;
import com.android.meige.view.MyGridView;
import com.android.meige.view.dialog.MainMsg;
import com.android.meige.view.group.CountDownTimerView;
import com.android.meige.view.group.ViewPagerIndicator;
import com.mcxtzhang.nestlistview.NestFullListView;
import com.mcxtzhang.nestlistview.NestFullListViewAdapter;
import com.mcxtzhang.nestlistview.NestFullViewHolder;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import okhttp3.Call;


/**
 * 团详情页
 */
public class Fragment_Mine_TeamDetail extends BaseLazyFragment {

    @BindView(R.id.top)
    View top;
    @BindView(R.id.ll_tuan_goods_stuats)
    ImageView llTuanGoodsStuats;
    @BindView(R.id.ll_tuan_goods_title)
    TextView llTuanGoodsTitle;
    @BindView(R.id.ll_tuan_goods_price_before)
    TextView llTuanGoodsPriceBefore;
    @BindView(R.id.ll_tuan_goods_tip)
    TextView llTuanGoodsTip;
    @BindView(R.id.ll_tuan_goods_price_after)
    TextView llTuanGoodsPriceAfter;
    @BindView(R.id.ll_tuan_goods_img)
    ImageView llTuanGoodsImg;
    @BindView(R.id.ll_tuan_goods_ll)
    RelativeLayout llTuanGoodsLl;
    @BindView(R.id.ll_tuan_detail_num)
    TextView llTuanDetailNum;
    @BindView(R.id.ll_tuan_detail_grid_avatar)
    MyGridView llTuanDetailGridAvatar;
    @BindView(R.id.ll_tuan_detail_msg)
    TextView llTuanDetailMsg;
    @BindView(R.id.ll_tuan_detail_time_finish)
    TextView llTuanDetailTimeFinish;
    @BindView(R.id.ll_tuan_detail_time_time)
    CountDownTimerView llTuanDetailTimeTime;
    @BindView(R.id.ll_tuan_detail_time_ll)
    LinearLayout llTuanDetailTimeLl;
    @BindView(R.id.ll_tuan_detail_info_isopen_tv)
    TextView llTuanDetailInfoIsopenTv;
    @BindView(R.id.ll_tuan_detail_info_isopen_ll)
    LinearLayout llTuanDetailInfoIsopenLl;
    @BindView(R.id.ll_tuan_detail_info_isopen_listview)
    NestFullListView llTuanDetailInfoIsopenListview;
    @BindView(R.id.ll_tuan_bottom_common_invite_tv)
    TextView llTuanBottomCommonInviteTv;
    @BindView(R.id.ll_tuan_bottom_common_invite)
    LinearLayout llTuanBottomCommonInvite;
    @BindView(R.id.ll_tuan_bottom_common_can)
    LinearLayout llTuanBottomCommonCan;
    @BindView(R.id.ll_tuan_bottom_fail_kai)
    LinearLayout llTuanBottomFailKai;
    @BindView(R.id.ll_tuan_bottom_succed_order)
    LinearLayout llTuanBottomSuccedOrder;
    @BindView(R.id.detail_list_laituantuijiang)
    NestFullListView detailListLaituantuijiang;
    @BindView(R.id.ll_pintuanvis)
    LinearLayout llPintuanvis;
    @BindView(R.id.ll_liucheng)
    LinearLayout llLiucheng;
    @BindView(R.id.detail_liucheng_detail_tv)
    TextView detailLiuchengDetailTv;

    @BindView(R.id.pager)
    ViewPager pager;
    @BindView(R.id.indicator)
    ViewPagerIndicator indicator;
    @BindView(R.id.detail_like_grid)
    MyGridView detailLikeGrid;
    @BindView(R.id.scroll)
    ScrollView scroll;
    @BindView(R.id.click_resetnetwork)
    LinearLayout clickResetnetwork;
    @BindView(R.id.progress)
    RelativeLayout progress;
    @BindView(R.id.no_data_tv)
    TextView noDataTv;
    @BindView(R.id.no_data)
    RelativeLayout noData;
    @BindView(R.id.ll_normal)
    LinearLayout llNormal;
    @BindView(R.id.ll_tuan_detail_jieti_num)
    TextView llTuanDetailJietiNum;
    @BindView(R.id.team_max)
    TextView teamMax;
    @BindView(R.id.main_top_right)
    ImageView main_top_right;
    @BindView(R.id.team_seekbar)
    SeekBar teamSeekbar;
    @BindView(R.id.ll_tuan_detail_grid_jieti)
    MyGridView llTuanDetailGridJieti;
    @BindView(R.id.ll_jieti)
    LinearLayout llJieti;

    private FragmentActivity mcontext;
    private View view;
    private LayoutInflater inflater;
    private ArrayList<MainList.MainListdata.Mainlistdata> listdata = new ArrayList<>();
    private boolean networkConnected;
    private GridDetaillikeAdapt adapter;
    private static final String ARG_PARAM1 = "param1";
    private String order_sn;
    private int goods_id;
    private MyAdapter Adapter_avatar;
    private int common_id;
    private int detail_id;
    private String goods_img_cover;
    private String goods_name;
    private String getShare_links;
    private ZixuanAdapt zixuanAdapt;
    private String share_content;
    private ShareDetail mInfo;
    private String spec = "";
    private String num = "1";
    private List<MainDetail.DataBean.GoodsItemBean> goodsItemBeen;
    private int type;
    private boolean isopen;

    public Fragment_Mine_TeamDetail() {

    }

    public static Fragment_Mine_TeamDetail newInstance(String need_id) {
        Fragment_Mine_TeamDetail fragment = new Fragment_Mine_TeamDetail();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, need_id);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            order_sn = getArguments().getString(ARG_PARAM1);
        }
    }

    @Override
    protected void initPrepare() {
        initUI();
    }

    @Override
    protected void onInvisible() {

    }

    @Override
    protected void initData() {
        GetDataBanner();
        GetDataTuan(order_sn);
        GetDataListData("&typeid=1");
    }

    @Override
    protected View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        this.inflater = inflater;
        view = inflater.inflate(R.layout.fragment_mine_order_tuan, container, false);
        mcontext = getActivity();
        ButterKnife.bind(this, view);
        return view;
    }

    private void initUI() {
        detailLiuchengDetailTv.setText("开团参团>邀请参团>人满成团");
        llLiucheng.setVisibility(View.GONE);
        scroll.smoothScrollTo(0, 0);
        top.setFocusable(true);
        top.setFocusableInTouchMode(true);
        top.requestFocus();
        llTuanGoodsPriceBefore.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
        Adapter_avatar = new MyAdapter(listinfo);
        llTuanDetailGridAvatar.setAdapter(Adapter_avatar);
        llTuanDetailInfoIsopenListview.setAdapter(new NestFullListViewAdapter<ShareDetail.DataBean.MemberBean>(R.layout.item_share_info, listinfo) {
            @Override
            public void onBind(int position, ShareDetail.DataBean.MemberBean testBean, NestFullViewHolder holder) {
                holder.setText(R.id.item_share_memberinfo_name, testBean.getMobile());
                ObjectUtils.photoCircle(mcontext, testBean.getAvatar(), (ImageView) holder.getView(R.id.item_share_memberinfo_img));
                if (position == 0) {
                    holder.setText(R.id.item_share_memberinfo_time, testBean.getC_time() + " 开团");
                } else {
                    holder.setText(R.id.item_share_memberinfo_time, testBean.getC_time() + " 参团");

                }
            }
        });
        isopen = false;
        if (isopen) {
            llTuanDetailInfoIsopenListview.setVisibility(View.VISIBLE);
        } else {
            llTuanDetailInfoIsopenListview.setVisibility(View.GONE);
        }

        zixuanAdapt = new ZixuanAdapt(jieti_list);
        llTuanDetailGridJieti.setAdapter(zixuanAdapt);
        adapter = new GridDetaillikeAdapt(mcontext, listdata);
        detailLikeGrid.setAdapter(adapter);
        detailLikeGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                ObjectUtils.ToDetailActivity(mcontext, 1, listdata.get(position).getId(), "");

            }
        });
        showRecommend(list_tuijian, detailListLaituantuijiang);
    }

    @OnClick({R.id.detail_liucheng_detail_ll, R.id.ll_tuan_goods_ll, R.id.ll_tuan_detail_info_isopen_ll,
            R.id.ll_tuan_bottom_common_invite, R.id.ll_tuan_bottom_common_can, R.id.ll_tuan_bottom_fail_kai, R.id.ll_tuan_bottom_succed_order
            , R.id.main_top_right, R.id.main_top_back})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.detail_liucheng_detail_ll:
                MainMsg mainMsg = new MainMsg(mcontext);
                mainMsg.show(mcontext.getWindow().getDecorView(), 7, null);
                break;
            case R.id.ll_tuan_goods_ll:
                ObjectUtils.ToDetailActivity(mcontext, 1, goods_id + "", "");
                break;
            case R.id.main_top_back:
                mcontext.finish();
                break;
            case R.id.ll_tuan_detail_info_isopen_ll:
                isopen = !isopen;
                if (isopen) {
                    llTuanDetailInfoIsopenListview.setVisibility(View.VISIBLE);
                    llTuanDetailInfoIsopenTv.setText("收起拼团列表");
                } else {
                    llTuanDetailInfoIsopenListview.setVisibility(View.GONE);
                    llTuanDetailInfoIsopenTv.setText("展开拼团列表");
                }
                break;
            case R.id.main_top_right:
            case R.id.ll_tuan_bottom_common_invite:
                ToShare();
                break;
            case R.id.ll_tuan_bottom_common_can:
                //参团
                if (LoginState.getInstance().isLogin(mcontext)) {
                    ToPay(type, 2);
                } else {
                    startActivity(new Intent(mcontext, LoginActivity.class));
                }
//                ObjectUtils.ToDetailActivity(mcontext, 2, goods_id + "", "" + common_id);
//                MyLog.e("common_id", common_id+"");
                break;
            case R.id.ll_tuan_bottom_fail_kai:
                ObjectUtils.ToDetailActivity(mcontext, 1, goods_id + "", "");
                break;
            case R.id.ll_tuan_bottom_succed_order:
                String getid = LoginState.getInstance().getid(mcontext);
                String getpd = LoginState.getInstance().getpd(mcontext);
                if (!getid.equals("") && !getpd.equals("")) {
                    Intent intent_order = new Intent(mcontext, MainTab.class);
                    intent_order.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TAB_SORT_SHOW_ID, 0);
                    intent_order.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TAB_SORT_SHOW_TYPE, 4);
                    startActivity(intent_order);
                } else {
                    startActivity(new Intent(mcontext, LoginActivity.class));
                }
                break;
        }
    }

    /**
     * 商品规格
     */
    public void showBottomPop(View v, int check, String s) {
        CheckInchPopWindow1 popWindow = new CheckInchPopWindow1(mcontext, mInfo, s, detail_id + "", check, "");
        popWindow.setData(check);
        popWindow.showAsDropDown(v);
//        PopDetailSpecChoose popWindow = new PopDetailSpecChoose(mcontext,mInfo);

    }

    private void ToPay(int typeid, int check) {
        Intent intent = new Intent(mcontext, PayActivity.class);
        if (goodsItemBeen != null) {
            showBottomPop(mcontext.getWindow().getDecorView(), check, "");
        } else {
            intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TO_PAY_ID, detail_id);
            intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TO_PAY_NUM, num);
            intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TO_PAY_SPEC, spec);
            intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TO_PAY_COMMON_ID, common_id);
            intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TO_PAY_OPTION, "");
            intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TO_PAY_TYPEID, typeid);
            startActivity(intent);
        }
    }

    private void ToShare() {
        Intent share = new Intent(mcontext, TransparentActivity.class);
        share.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TO_TRANS_SHOW_TYPE, 1);
        share.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TO_TRANS_SHOW_TITLE, share_content);
        share.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TO_TRANS_SHOW_CONTENT, "这么划算真的不来抢吗");
        share.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TO_TRANS_SHOW_IMAGEURL, goods_img_cover);
        share.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TO_TRANS_SHOW_LINK, getShare_links);
        mcontext.startActivity(share);
    }

    private class MyAdapter extends BaseAdapter {

        ArrayList<ShareDetail.DataBean.MemberBean> listinfo;

        public MyAdapter(ArrayList<ShareDetail.DataBean.MemberBean> listimg) {
            this.listinfo = listimg;
        }

        @Override
        public int getCount() {
            return listinfo.size();
        }

        @Override
        public BaseObject getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = inflater.inflate(R.layout.item_share_avatar, null);
            TextView is_tuanzhang = (TextView) view.findViewById(R.id.is_tuanzhang);
            ImageView img = (ImageView) view.findViewById(R.id.is_img);
            ObjectUtils.photoCircle(mcontext, listinfo.get(position).getAvatar(), img);
            if (position == 0) {
                is_tuanzhang.setVisibility(View.VISIBLE);
            } else {
                is_tuanzhang.setVisibility(View.GONE);
            }
            return view;
        }
    }

    private ArrayList<Banner.Bannerdata> Bannerlist = new ArrayList<>();

    //获取轮播图数据
    private void GetDataBanner() {
        indicator.autoScroll(getFragmentManager(), pager, 1);
        String address = ConstantsUrl.domain + ConstantsUrl.FRAGMENT1_BANNER;
        HttpUtils.get(address, null, new BannerCallback() {

            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(Banner response, int id) {
                Bannerlist.clear();
                List<Banner.Bannerdata> data = response.getData();
                if (ObjectUtils.listHasData(data)) {
                    Bannerlist.addAll(data);
                    indicator.setViewPager(Bannerlist);
                    indicator.setNotifyDataSetChanged();
                }
            }
        });
    }

    @Override
    public void onPause() {
        super.onPause();
        indicator.setVisible(false);
    }

    @Override
    public void onStart() {
        super.onStart();
        indicator.setVisible(true);
    }

    private ArrayList<ShareDetail.DataBean.TeamListBean> list_tuijian = new ArrayList<>();
    private ArrayList<ShareDetail.DataBean.MemberBean> listinfo = new ArrayList<>();
    ArrayList<String> midlist = new ArrayList<>();

    private void GetDataTuan(String id) {
        networkConnected = ObjectUtils.isNetworkConnected(mcontext);
        if (networkConnected) {
            String address = ConstantsUrl.domain + ConstantsUrl.MAINLIST_DETAILSHARE + "?common_id=" + id;
            MyLog.e("分享", "" + address);
            final String getid = LoginState.getInstance().getid(mcontext);
            String getpd = LoginState.getInstance().getpd(mcontext);
            HashMap<String, String> header = new HashMap<>();
            header.put("UID", getid);
            header.put("UPSW", getpd);
            HttpUtils.get(address, header, null, new ShareDteailCallback() {
                @Override
                public void onError(Call call, Exception e, int id) {
                    ObjectUtils.GetDataNet(clickResetnetwork, progress, 2);
                }

                @Override
                public void onResponse(ShareDetail response, int id) {
                    if (response == null) {
                        ObjectUtils.GetDataNet(clickResetnetwork, progress, 4);
                        return;
                    }
                    ShareDetail.DataBean data = response.getData();
                    if (response.getCode() == 0 && data != null) {
                        mInfo = response;
                        //商品规格属性
                        goodsItemBeen = data.getGoods_item();
                        detail_id = data.getGoods_id();
                        common_id = data.getId();
                        getShare_links = data.getShare_links();
                        goods_name = data.getGoods_name();
                        share_content = data.getShare_content();
                        goods_img_cover = data.getGoods_img_cover();
                        goods_id = data.getGoods_id();
                        ObjectUtils.photo(mcontext, goods_img_cover, llTuanGoodsImg);
                        llTuanGoodsTitle.setText(goods_name);
                        llTuanGoodsPriceAfter.setText("￥" + data.getGoods_team_price());
                        llTuanGoodsPriceBefore.setText("￥" + data.getGoods_price());
                        llTuanDetailNum.setText("" + data.getTeam_num_no());
                        llTuanDetailMsg.setText(data.getTeam_num_no_msg());
                        if (data.getAA_team_price().equals("")) {
                            llTuanGoodsTip.setText("拼团为您节省了" + data.getTeam_save() + "元");
                        } else {
                            llTuanGoodsTip.setText(data.getAA_team_price());
                        }
                        listinfo.clear();
                        jieti_list.clear();
                        List<ShareDetail.DataBean.MemberBean> member = data.getMember();
                        if (ObjectUtils.listHasData(member)) {
                            listinfo.addAll(member);
                            if (!data.getTeam_status().equals("10")) {
                                listinfo.add(new ShareDetail.DataBean.MemberBean(ConstantsUrl.baseDomain + "style/img/txbg.png", "等你来"));
                            }
                            llTuanDetailInfoIsopenListview.updateUI();
                            midlist.clear();
                            for (int i = 0; i < member.size(); i++) {
                                midlist.add(member.get(i).getMid());
                            }
                            MyLog.e("用户id", midlist.toString());
                            switch (data.getTeam_status()) {
                                case "1":
                                    if (midlist.contains(getid)) {
                                        llTuanBottomCommonInvite.setVisibility(View.VISIBLE);
                                        llTuanBottomCommonInviteTv.setText("还差" + data.getTeam_num_no() + "人成团，点击右上角邀请好友");
                                        ToShare();
                                    } else {
                                        llTuanBottomCommonCan.setVisibility(View.VISIBLE);
                                    }
                                    break;
                                case "2":
                                    llTuanGoodsStuats.setVisibility(View.VISIBLE);
                                    llTuanBottomFailKai.setVisibility(View.VISIBLE);
                                    main_top_right.setVisibility(View.INVISIBLE);
                                    break;
                                case "10":
                                    llTuanGoodsStuats.setVisibility(View.VISIBLE);
                                    llTuanGoodsStuats.setImageResource(R.mipmap.share_succed);
                                    llTuanBottomFailKai.setVisibility(View.VISIBLE);
                                    main_top_right.setVisibility(View.INVISIBLE);
                                    break;
                            }
                        }
                        List<ShareDetail.DataBean.StepArrayBean> step_array = data.getStep_array();
                        if (ObjectUtils.listHasData(step_array)) {
                            llJieti.setVisibility(View.VISIBLE);
                            llTuanDetailJietiNum.setText(data.getTeam_max() - (Integer.parseInt(data.getTeam_num_yes())) + "");
                            teamSeekbar.setMax(data.getTeam_max());
                            teamMax.setText(data.getTeam_max() + "人");
                            teamSeekbar.setProgress(Integer.parseInt(data.getTeam_num_yes()));
                            jieti_list.addAll(step_array);
                            for (int i = 0; i < jieti_list.size(); i++) {
                                if (data.getGoods_team_price().equals(jieti_list.get(i).getStep_value())) {
                                    zixuanAdapt.select(i);
                                }
                            }
                            zixuanAdapt.notifyDataSetChanged();
                        } else {
                            llNormal.setVisibility(View.VISIBLE);
                            Adapter_avatar.notifyDataSetChanged();
                        }
                        if (data.getEnd_time() > 0) {
                            llTuanDetailTimeTime.setTime(data.getEnd_time());
                            llTuanDetailTimeTime.start();
                            llTuanDetailTimeLl.setVisibility(View.VISIBLE);
                        } else {
                            llTuanDetailTimeFinish.setVisibility(View.VISIBLE);
                        }
                        if (!data.getTeam_status().equals("1")) {
                            if (data.getTeam_list() != null) {
                                if (data.getTeam_list().size() > 0) {
                                    llPintuanvis.setVisibility(View.VISIBLE);
                                    list_tuijian.addAll(data.getTeam_list());
                                    detailListLaituantuijiang.updateUI();
                                } else {
                                    llPintuanvis.setVisibility(View.GONE);
                                }
                            }
                        } else {
                            llPintuanvis.setVisibility(View.GONE);
                        }
                        ObjectUtils.GetDataNet(clickResetnetwork, progress, 1);
                    } else {
                        noData.setVisibility(View.VISIBLE);
                        noDataTv.setText(response.getMsg());
                        noDataTv.setVisibility(View.VISIBLE);
                    }
                }
            });
        } else {
            ObjectUtils.GetDataNet(clickResetnetwork, progress, 4);
            ObjectUtils.toast(mcontext, "网络未连接");
        }
    }

    //获取列表数据
    private void GetDataListData(String type) {
        String address = ConstantsUrl.domain + ConstantsUrl.MAIN_LISTDATA + "?size=" + 8 + type;
        networkConnected = ObjectUtils.isNetworkConnected(mcontext);
        if (networkConnected) {
            HttpUtils.get(address, null, new MainListCallback() {

                @Override
                public void onError(Call call, Exception e, int id) {
                    ObjectUtils.GetDataNet(clickResetnetwork, progress, 2);
                }

                @Override
                public void onResponse(MainList response, int id) {
                    if (response == null) {
                        return;
                    }
                    listdata.clear();
                    MainList.MainListdata data = response.getData();
                    if (data != null && ObjectUtils.listHasData(data.getList())) {
                        listdata.addAll(data.getList());
                        adapter.notifyDataSetChanged();
                    }
                }
            });
        }
    }

    @OnClick(R.id.click_resetnetwork_refresh)
    public void onClick() {
        ObjectUtils.GetDataNet(clickResetnetwork, progress, 3);
        GetDataBanner();
        GetDataTuan(order_sn);
        GetDataListData("&typeid=1");
    }

    private int pos_zixuan = 0;
    private List<ShareDetail.DataBean.StepArrayBean> jieti_list = new ArrayList<>();

    private class ZixuanAdapt extends BaseAdapter {

        List<ShareDetail.DataBean.StepArrayBean> use_list;

        public ZixuanAdapt(List<ShareDetail.DataBean.StepArrayBean> use_list) {
            this.use_list = use_list;
        }

        // 选中当前选项时，让其他选项不被选中
        public void select(int position) {
            pos_zixuan = position;
            notifyDataSetChanged();
        }

        @Override
        public int getCount() {
            return use_list.size();
        }

        @Override
        public BaseObject getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {
            View inflate = inflater.inflate(R.layout.item_gird_detail_zixuan, null);
            TextView tv = (TextView) inflate.findViewById(R.id.tv);
            tv.setText(use_list.get(position).getStep_key() + "人/" + use_list.get(position).getStep_value() + "元");
            tv.setBackgroundColor(Color.parseColor("#00000000"));
            if (pos_zixuan == position) {
                tv.setTextColor(Color.parseColor("#FF2741"));
            } else {
                tv.setTextColor(Color.parseColor("#333333"));
            }
            return inflate;
        }
    }

    private void showRecommend(final List<ShareDetail.DataBean.TeamListBean> list, NestFullListView addview) {
        addview.setAdapter(new NestFullListViewAdapter<ShareDetail.DataBean.TeamListBean>(R.layout.item_grid_detail_recommend, list_tuijian) {
            @Override
            public void onBind(int position, ShareDetail.DataBean.TeamListBean testBean, NestFullViewHolder holder) {
                int total = Integer.parseInt(testBean.getTeam_num());
                int total_yes = Integer.parseInt(testBean.getTeam_num_yes());
                int total_no = total - total_yes;
                holder.setText(R.id.item_grid_detail_recommend_phone, testBean.getUsername());
                holder.setText(R.id.item_grid_detail_recommend_tuanshu, "还差" + total_no + "人成团");
                ObjectUtils.photoCircle(mcontext, testBean.getAvatar(), ((ImageView) holder.getView(R.id.item_grid_detail_recommend_img)));
                CountDownTimerView item_grid_detail_recommend_time = holder.getView(R.id.RushBuyCountDownTimerView);
                item_grid_detail_recommend_time.setTime(testBean.getEnd_time());
                item_grid_detail_recommend_time.start();
            }
        });

        addview.setOnItemClickListener(new NestFullListView.OnItemClickListener() {
            @Override
            public void onItemClick(NestFullListView nestFullListView, View view, int pos) {
                Intent intent_tuan = new Intent(mcontext, BaseObject.class);
                intent_tuan.putExtra("title", "团详情");
                intent_tuan.putExtra("need_id", list.get(pos).getId());
                mcontext.startActivity(intent_tuan);
            }
        });
    }
}
